<template>
  <div :key="key">
    <center>
      <h2>南京市家庭养老床位运营补贴申请表</h2>
    </center>
    <!-- 基本情况 -->
    <table align="center" border="1" cellpadding="5" cellspacing="0" width="100%" class="table1">
      <caption>所属时间:{{ data.applyYear }} 年{{data.applyYearQuarterLabel}}</caption>
      <caption>基本情况</caption>
      <tr>
        <td>机构名称</td>
        <td>{{ data.organizationName }}</td>
        <td>法人代表人</td>
        <td>{{ data.deputyUserName }}</td>
      </tr>
      <tr>
        <td>机构地址</td>
        <td>{{data.organizationAddress }}</td>
        <td>联系电话</td>
        <td>{{ data.organizationPhone }}</td>
      </tr>
      <tr>
        <td>机构等级</td>
        <td>{{ data.organizationLevelLabel }}</td>
        <td>银行账号</td>
        <td>{{ data.bankAccount }}</td>
      </tr>
      <tr>
        <td>营业执照（民非）证号</td>
        <td>{{ data.organizationLicense }}</td>
        <td>机构设置证号（备案</td>
        <td>{{ data.organizationFiling }}</td>
      </tr>
      <tr>
        <td>开户银行</td>
        <td>{{ data.bankName }}</td>
        <td>银行账号</td>
        <td>{{ data.bankAccount }}</td>
      </tr>
      <tr>
        <td>养老机构服务质量大检查指南基础指标是否全部达标</td>
        <td colspan="3">{{data.baseQualityStandardLabel }}</td>
      </tr>
    </table>
    <br/>
    <!-- 员工概括 -->
    <table align="center" border="1" cellpadding="5" cellspacing="0" width="100%" class="table2">
      <caption>员工概括</caption>
      <tr>
        <td>员工总数</td>
        <td>{{data.staffNum }}</td>
        <td>持证人数</td>
        <td>{{data.certStaffNum }}</td>
        <td>管理人员</td>
        <td>{{data.managerNum }}</td>
        <td>持证人数</td>
        <td>{{ data.certManagerNum }}</td>
      </tr>
    </table>
    <br/>
    <!-- 申请内容 -->
    <table align="center" border="1" cellpadding="5" cellspacing="0" width="100%" class="table3">
      <caption>申请内容</caption>
      <tr style="font-weight: 700;">
        <td rowspan="2">月份</td>
        <td rowspan="2">机构等级</td>
        <td colspan="2">介助</td>
        <td colspan="2">介护</td>
        <td rowspan="2">基准补贴总金额</td>
        <td rowspan="2">等级系数</td>
        <td rowspan="2">基准总金额x等级系数</td>
      </tr>
      <tr style="font-weight: 700;">
        <td>人</td>
        <td>金额</td>
        <td>人</td>
        <td>金额</td>
      </tr>
      <tr v-for="(item,index) in applyData" :key="index">
        <td>{{item.belongYearMonth }}月份</td>
        <td style="font-weight: 500;">{{ data.organizationLevelLabel }}</td>
        <td>{{ item.assistNum }}</td>
        <td>{{ item.assistAmount }}</td>
        <td>{{ item.careNum }}</td>
        <td>{{ item.careAmount }}</td>
        <td>{{ item.baseSubsidyTotalAmount }}</td>
        <td>{{ item.levelFactor }}</td>
        <td>{{ item.baseSubtotal }}</td>
      </tr>
      <tr>
        <td colspan="2" style="font-weight: 700;">总计</td>
        <td>{{ columnSum('assistNum') }}</td>
        <td>{{ columnSum('assistAmount') }}</td>
        <td>{{ columnSum('careNum') }}</td>
        <td>{{ columnSum('careAmount') }}</td>
        <td>{{ columnSum('baseSubsidyTotalAmount') }}</td>
        <td>{{ columnSum('levelFactor') }}</td>
        <td>{{ columnSum('baseSubtotal') }}</td>
      </tr>
      <tr>
        <td style="font-weight: 700;">补贴金额</td>
        <td colspan="3">{{ data.subsidyTotalAmount }}</td>
        <td style="font-weight: 700;">补贴金额（大写）</td>
        <td colspan="4">{{ data.subsidyTotalAmountText }}</td>
      </tr>
      <tr>
        <th colspan="9">本机构承诺以上及所附数据资料真实有效，如有不实，愿承担相关处罚。</th>
      </tr>
      <tr>
        <th colspan="9">负责人签名：{{ data.fillingUserName }} （单位盖章）</th>
      </tr>
      <tr>
        <th colspan="9">{{ handleDate(data.fillingDate) }}</th>
      </tr>
    </table>
    <br/>
    <!--审核意见  -->
    <table align="center" border="1" cellpadding="0" cellspacing="0" width="100%" class="table4">
      <caption>审核意见</caption>
      <tr>
        <td rowspan="2">区民政部门意见</td>
        <td rowspan="2">{{ data.approvalCivilAffairNote }}</td>
        <td>区民政局：                 （章）</td>
      </tr>
      <tr>
        <td>{{ handleDate(data.approvalCivilAffairDate) }}</td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod/index'
type Props = {
  nowRowData?: any
}
const props = withDefaults(defineProps<Props>(), {
  nowRowData: {}
})
let data: any = reactive({})
data = props.nowRowData
let applyData: any = reactive([])
let key = ref(1)
// 获取申请数据
let getApplyData = (id) => {
  apiMod.dpHomeBedApply_page({ headId: id,pageParaPO:{size:1000000,current:1}}).then(res => {
    applyData = res.data.records
    key.value = Math.random()
  })
}
getApplyData(props.nowRowData.soleValue)

// 列统计
const columnSum = (prop)=> {
  console.log('---====',)
  let sum = 0
  if(prop && applyData.length>0){
    applyData.forEach(el => {
      if(el[prop]){
        sum+=el[prop]
      }
    });
  }
  return sum
}
// 处理时间，年月日
const handleDate = (date) =>{
  if(date){
    let dateList = date.split('-')
    return dateList[0]+'年'+dateList[1]+'月'+dateList[2]+'日'
  }else{
    return '年 月 日'
  }
}
</script>
<style scoped lang="scss">
.table1>tr>td:nth-child(odd) {
  font-weight: 700;
}
.table2>tr>td:nth-child(odd) {
  font-weight: 700;
}
.table4>tr>td:nth-child(odd) {
  font-weight: 700;
}
</style>